<template>
    <div class="fa" style="background: #F2F3F5">
        <div class="top">
            医院
        </div>

        <div className="content" v-for="el in arr">
            <img src="https://img1.dxycdn.com/2020/0821/576/5341793254857661343-22.png" alt="" />
            <div className="txt">
                <div className="txt_top">
                    <span className="sp1">
                        {{ el.name }}
                    </span>
                    <span className="sp2">
                        图标
                    </span>
                    <span className="sp3">
                        {{ el.rating }}
                    </span>
                </div>
                <div>
                    {{ el.address }}
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref, onBeforeMount,onBeforeUpdate } from "vue"
import axios from "axios";
import { useRouter } from "vue-router";
import store from "@/store/S_zc"
let data = store().cache

let router = useRouter()

let arr :any= ref({})

onBeforeMount(() => {
    seaeched("", data.ar[2])
})
onBeforeUpdate(()=>{
    seaeched("", data.ar[2])
})

async function seaeched(x: string, y?: string[]) {
    if (y) {
        if (y[0] == undefined) {
            // 显示没有
        } else {
            let re: any = await axios("/path/search", { params: { department: x, sec: true, table: y[0], field: y[1] } })
            arr.value = re.data.sql
            console.log(typeof(arr.value),arr.value, "hospital")
        }

    } else {
        // let re: any = await axios("/path/search", { params: { department: x, table: data.ar[0][0], field: data.ar[0][1] } })
        // arr.value = re.data.sql
    }
    if (arr.value[0] ==undefined) {
        router.push('/Null')
    }

}
</script>

<style scoped  lang="scss">
.fa {
    width: 1180px;

    .top {
        font-size: 20px;
        height: 60px;
        margin-bottom: 20px;
        background-color: white;
    }
}

.content {
    background-color: white;
    display: flex;
    justify-content: flex-start;
    width: 1120px;
    height: 100px;
    padding: 28px 30px;
    margin-bottom: 20px;

    img {
        width: 98px;
        height: 98px;
        margin-right: 24px;
        border-radius: 4px;
        border: 1px solid rgba(0, 0, 0, .05);
    }

    .txt {
        .txt_top{
            margin-bottom: 36px;
            .sp1 {
            font-size: 28px;
            font-weight: 600;
            line-height: 32px;
            color: #252a33;
            margin-right: 12px;
        }
        }

    }
}
</style>